// 过往排行  todo 未修改虚拟数据
var numberFormate = iot.getNumberFormat("0");
var timeNotYearFormatMap = {
    'year': "%Y",
    'month': "%m",
    'day': "%m-%d",
    'hour': "%m-%d %H"
};
dev.action = function(resp,param){
    var theTime = param.time;
    var workSpace = param.workSpace;
    var db = iot.db();
    var format;
    var resultData = {
        content : iot.list()
    };

    var Collections = Java.type("java.util.Collections");
    var Comparator = Java.type("java.util.Comparator")
    var Printer = Java.extend(Comparator, {
        compare : function (o1, o2) {
            if (o1.useNum > o2.useNum) {
                return -1;
            }
            if (o2.useNum > o1.useNum) {
                return 1;
            }
            return 0;
        }
    })
    var resultList = iot.list();
    var timeDataList = ["2014", "2015", "2016", "2017", "2018", "2019"];
    // 开始组装数据
    for (var i = 0; i < timeDataList.length; i++) {
        resultList.add({rank: i, year: timeDataList[i], useNum: parseInt(Math.random()*87877776), increase: parseInt(Math.random()*50)+'%'});
    }
    Collections.sort(resultList, new Printer());
    for (var i = 0; i < resultList.size(); i++) {
       var obj=resultList.get(i)
        obj.rank = i+1
    }
    resultData.content = resultList;
    resp.setJsData(resultData);

}
